import config as conf
from importlib import import_module as im

import tornado.web as web
import os

urlpatterns = []

for app in conf.INSTALLED_APPS:
    cmd = app + '.urls' 
    urlpatterns = urlpatterns + getattr(im(cmd), 'urlpatterns')


def get_application():
    app = web.Application(
        urlpatterns,
        static_path=os.path.join(os.path.dirname(__file__), 'html'),        
        debug=conf.DEBUG,
    )
    return app